package com.mark.mall.web.platform.myMethod;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author admin
 */
@Component
public class MySqlInjector extends DefaultSqlInjector {
    @Override
    public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
        List<AbstractMethod> methodList = super.getMethodList(mapperClass);
        // Entity属性全部更新，为null也更新为null
        // i -> ! "xxx".equals(i.getColumn()) 过滤字段
        methodList.add(new AlwaysUpdateSomeColumnById((i -> i.getFieldFill() != FieldFill.INSERT)));
        methodList.add(new DeleteAll());
        methodList.add(new FindAll());
        return methodList;
    }
}
